package com.witte.serviceImp;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.witte.dao.UserMapper;
import com.witte.entity.User;
import com.witte.service.UserService;



@Service
public class UserServiceImp implements UserService{
	
	@Autowired
	UserMapper userMapper;
	

	@Override
	public User login(User user) {
		User userTemp=userMapper.selectByName(user.getName());
		if(userTemp==null)
			return null;
		if(userTemp.getPassword().equals(user.getPassword()))
			return userTemp;
		else
			return null;
	}

	@Override
	public List<User> getRoleUser(int role) {
		List<User> userTemp=userMapper.selectByRole(role, 0);
		return userTemp;
	}

	@Override
	public User getUserByName(String name) {
		// TODO Auto-generated method stub
		return userMapper.selectByName(name);
	}

}
